package pe.com.cineplanet.service.impl;

import java.util.List;

import pe.com.cineplanet.bean.Articulo;
import pe.com.cineplanet.bean.Rubro;
import pe.com.cineplanet.bean.User;
import pe.com.cineplanet.dao.ArticuloDAO;
import pe.com.cineplanet.dao.RubroDAO;
import pe.com.cineplanet.dao.UserDAO;
import pe.com.cineplanet.service.Service;

public class ServiceImpl implements Service {

	private UserDAO userDAO;
	private ArticuloDAO articuloDAO;
	private RubroDAO rubroDAO;
	
	public User login(String username, String password){
		
		User user =  userDAO.select(username, password);
		if(user!=null){
			
			if( user.isActive() ){
				
				user.getRole().setPolitics( userDAO.getPolitics(user.getId()) );
				
			}
			
			
		}
		
		return user;
	}
	
	public void save(Articulo articulo, boolean edit){
		if(edit){
			articuloDAO.update(articulo);
		}
	}
	public void delete(Articulo articulo){
		articuloDAO.delete(articulo);
	}
	public List<Articulo> listArticulosByName(String descrip){
		return articuloDAO.selectList(descrip);
	}
	public Articulo getArticulo(String idArticulo){
		return articuloDAO.select(idArticulo);
	}
	public List<Rubro> listRubro(){
		return rubroDAO.selectList();
	}

	public UserDAO getUserDAO() {
		return userDAO;
	}

	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}

	public ArticuloDAO getArticuloDAO() {
		return articuloDAO;
	}

	public void setArticuloDAO(ArticuloDAO articuloDAO) {
		this.articuloDAO = articuloDAO;
	}

	public RubroDAO getRubroDAO() {
		return rubroDAO;
	}

	public void setRubroDAO(RubroDAO rubroDAO) {
		this.rubroDAO = rubroDAO;
	}
	
	
	
	
	
}
